/*******************************************************************************
* @Filename      : bsp_dma.c

* @Description   : bsp_dma.c

* @Version       : 1.0.0

* @Date          : 2023.12.2
*******************************************************************************/

/* Includes ------------------------------------------------------------------*/
#include "bsp_dma.h"

/* Private typedef -----------------------------------------------------------*/

/* Private define ------------------------------------------------------------*/

/* Global variables ----------------------------------------------------------*/
__IO uint32_t buffer[2][512];

/* Private variables ---------------------------------------------------------*/
//static uint32_t nulldata = 0xFFFF;

/* Private function prototypes -----------------------------------------------*/

/* Exported functions --------------------------------------------------------*/
/*******************************************************************************
* @Name      : BSP_DMA_Init
* @Purpose   : BSP_DMA_Init
* @Param     : None
* @Retval    : None
*******************************************************************************/
void BSP_DMA_Init(void)
{
    DMA_InitTypeDef  DMA_InitStruct;

    RCC_AHBPeriphClockCmd(RCC_AHBENR_DMA1, ENABLE);

    DMA_DeInit(DMA1_Channel2);

    DMA_StructInit(&DMA_InitStruct);
    DMA_InitStruct.DMA_PeripheralBaseAddr = (uint32_t)&(SPI1->RXREG);
    DMA_InitStruct.DMA_MemoryBaseAddr     = (uint32_t)&(SPI2->TXREG);
    DMA_InitStruct.DMA_DIR                = DMA_DIR_PeripheralSRC;
    DMA_InitStruct.DMA_BufferSize         = 0;
    DMA_InitStruct.DMA_PeripheralInc      = DMA_PeripheralInc_Disable;
    DMA_InitStruct.DMA_MemoryInc          = DMA_MemoryInc_Disable;
    DMA_InitStruct.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
    DMA_InitStruct.DMA_MemoryDataSize     = DMA_MemoryDataSize_Byte;
    DMA_InitStruct.DMA_Mode               = DMA_Mode_Normal;
    DMA_InitStruct.DMA_Priority           = DMA_Priority_VeryHigh;
    DMA_InitStruct.DMA_M2M                = DMA_M2M_Disable;
    DMA_InitStruct.DMA_Auto_reload        = DMA_Auto_Reload_Disable;
    DMA_Init(DMA1_Channel2, &DMA_InitStruct);

    DMA_Cmd(DMA1_Channel2, DISABLE);

//    DMA_DeInit(DMA1_Channel3);

//    DMA_StructInit(&DMA_InitStruct);
//    DMA_InitStruct.DMA_PeripheralBaseAddr = (uint32_t)&(SPI1->TXREG);
//    DMA_InitStruct.DMA_MemoryBaseAddr     = (uint32_t)&(nulldata);
//    DMA_InitStruct.DMA_DIR                = DMA_DIR_PeripheralDST;
//    DMA_InitStruct.DMA_BufferSize         = 0;
//    DMA_InitStruct.DMA_PeripheralInc      = DMA_PeripheralInc_Disable;
//    DMA_InitStruct.DMA_MemoryInc          = DMA_MemoryInc_Disable;
//    DMA_InitStruct.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word;
//    DMA_InitStruct.DMA_MemoryDataSize     = DMA_MemoryDataSize_Word;
//    DMA_InitStruct.DMA_Mode               = DMA_Mode_Normal;
//    DMA_InitStruct.DMA_Priority           = DMA_Priority_VeryHigh;
//    DMA_InitStruct.DMA_M2M                = DMA_M2M_Disable;
//    DMA_InitStruct.DMA_Auto_reload        = DMA_Auto_Reload_Disable;
//    DMA_Init(DMA1_Channel3, &DMA_InitStruct);

//    DMA_Cmd(DMA1_Channel3, DISABLE);

//    DMA_DeInit(DMA1_Channel5);

//    DMA_StructInit(&DMA_InitStruct);
//    DMA_InitStruct.DMA_PeripheralBaseAddr = (uint32_t)&(SPI2->TXREG);
//    DMA_InitStruct.DMA_MemoryBaseAddr     = (uint32_t)&(buffer[0][0]);
//    DMA_InitStruct.DMA_DIR                = DMA_DIR_PeripheralDST;
//    DMA_InitStruct.DMA_BufferSize         = 0;
//    DMA_InitStruct.DMA_PeripheralInc      = DMA_PeripheralInc_Disable;
//    DMA_InitStruct.DMA_MemoryInc          = DMA_MemoryInc_Enable;
//    DMA_InitStruct.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word;
//    DMA_InitStruct.DMA_MemoryDataSize     = DMA_MemoryDataSize_Word;
//    DMA_InitStruct.DMA_Mode               = DMA_Mode_Normal;
//    DMA_InitStruct.DMA_Priority           = DMA_Priority_VeryHigh;
//    DMA_InitStruct.DMA_M2M                = DMA_M2M_Disable;
//    DMA_InitStruct.DMA_Auto_reload        = DMA_Auto_Reload_Disable;
//    DMA_Init(DMA1_Channel5, &DMA_InitStruct);

//    DMA_Cmd(DMA1_Channel5, DISABLE);
}

/* Overrride functions -------------------------------------------------------*/

/* Private functions ---------------------------------------------------------*/

/* End of File ---------------------------------------------------------------*/
